/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#include <QtGui/QLayout>
#include <QtGui/QMouseEvent>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QCheckBox>

#include "PlaneColliderControl.h"

namespace PQBuilder
{
	PlaneColliderControl::PlaneColliderControl(QWidget *parent,PQEngine::PlaneColliderComponent* component)
	{		
		if(component!=0){
			QGridLayout* grid=new QGridLayout(this);
			Ogre::Vector3 normal=component->getNormal();
			float distance=component->getDistance();

			QLabel* labelNormal=new QLabel(QObject::tr("Normal"),this);

			QLabel* labelNormalX=new QLabel("X",this);
			QLineEdit* editNormalX=new QLineEdit(this);
			labelNormalX->setAlignment(Qt::AlignHCenter);
			editNormalX->setText(QString::fromStdString(Ogre::StringConverter::toString(normal.x)));

			QLabel* labelNormalY=new QLabel("Y",this);
			QLineEdit* editNormalY=new QLineEdit(this);
			labelNormalY->setAlignment(Qt::AlignHCenter);
			editNormalY->setText(QString::fromStdString(Ogre::StringConverter::toString(normal.y)));

			QLabel* labelNormalZ=new QLabel("Z",this);
			QLineEdit* editNormalZ=new QLineEdit(this);
			labelNormalZ->setAlignment(Qt::AlignHCenter);
			editNormalZ->setText(QString::fromStdString(Ogre::StringConverter::toString(normal.z)));
			
			QLabel* labelDistance=new QLabel(QObject::tr("Distance"),this);
			QLineEdit* editDistance=new QLineEdit(this);
			editDistance->setText(QString::fromStdString(Ogre::StringConverter::toString(distance)));

			grid->addWidget(labelNormal,0,0,1,2);

			grid->addWidget(labelNormalX,1,0);
			grid->addWidget(editNormalX,1,1);

			grid->addWidget(labelNormalY,2,0);
			grid->addWidget(editNormalY,2,1);

			grid->addWidget(labelNormalZ,3,0);
			grid->addWidget(editNormalZ,3,1);
			
			grid->addWidget(labelDistance,4,0);
			grid->addWidget(editDistance,4,1);

			this->setLayout(grid);
		}

		this->setMaximumHeight(5*28);
	}

	PlaneColliderControl::~PlaneColliderControl()
	{
	}
	
}
